package indi.zhaosheng.rocktmq.consumer;

import java.util.function.Function;

/**
 * @author muluo
 * @description
 * @date 2020/5/5 15:13
 */
public class ConsumerAction {

    private ConsumerAction() {
    }

    private Function<String, Boolean> function;

    public static ConsumerAction build(Function<String, Boolean> function) {
        ConsumerAction action = new ConsumerAction();
        action.setFunction(function);
        return action;
    }

    private void setFunction(Function<String, Boolean> function) {
        this.function = function;
    }

    public boolean execute(String msg) {
        return reBool(function.apply(msg));
    }

    private boolean reBool(Boolean bl) {
        return bl == null ? false : bl;
    }


}
